<template>
<!--  <div id="login_container" style="height: 400px; width: 400px"></div>-->
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :sm="24" :lg="12" style="padding-left: 20px">
        <h2>单折线图</h2>
<!--        https://g2plot.antv.antgroup.com/zh/examples/column/basic/#color-->
        <div id="container" style="width: 600px;height: 400px"></div>

        <h2>双折线图</h2>
        <div id="container1" style="width: 600px;height: 400px"></div>

      </el-col>

      <el-col :sm="24" :lg="12" style="padding-left: 50px">
        <el-row>
          <el-col :span="12">
            <h2>环形图</h2>
            <div id="container2" style="width: 600px;height: 400px"></div>
            <h2>柱状图</h2>
            <div id="container3" style="width: 600px;height: 400px"></div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">

          </el-col>
          <el-col :span="6">

          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <el-divider />
  </div>
</template>
<script src="http://wwcdn.weixin.qq.com/node/wework/wwopen/js/wwLogin-1.2.7.js"></script>

<script>
import { Line,DualAxes,RingProgress,Column,Bar } from '@antv/g2plot';
fetch('https://gw.alipayobjects.com/os/bmw-prod/1d565782-dde4-4bb6-8946-ea6a38ccf184.json')
  .then((res) => res.json())
  .then((data) => {
    const line = new Line('container', {
      data,
      padding: 'auto',
      xField: 'Date',
      yField: 'scales',
      xAxis: {
        // type: 'timeCat',
        tickCount: 5,
      },
    });

    line.render();
  });

export default {
  name: "Index",
  data() {
    return {
      data : [
        { year: '1991', value: 3, count: 10 },
        { year: '1992', value: 4, count: 4 },
        { year: '1993', value: 3.5, count: 5 },
        { year: '1994', value: 5, count: 5 },
        { year: '1995', value: 4.9, count: 4.9 },
        { year: '1996', value: 6, count: 35 },
        { year: '1997', value: 7, count: 7 },
        { year: '1998', value: 9, count: 1 },
        { year: '1999', value: 13, count: 20 },
      ]
    };
  },
  created() {
    var wwLogin = new WwLogin({
      "id": "wx_reg",  //	企业页面显示二维码的DOM id
      "appid" : "ww397ffcc99ac27d17",
      "agentid" : "1000002",
      "redirect_uri" :"http://qrcode.honglinhangk.asia",
      "state": "",//该参数可用于防止csrf攻击
      "href": "",//自定义样式链接，企业可根据实际需求覆盖默认样式
      "lang": "zh",//自定义语言，支持zh、en；lang为空则从Headers读取Accept-Language，默认值为zh
    });
  },
  mounted() {



    const dualAxes = new DualAxes('container1', {
      data: [this.data, this.data],
      xField: 'year',
      yField: ['value', 'count'],
      geometryOptions: [
        {
          geometry: 'line',
          color: '#5B8FF9',
        },
        {
          geometry: 'line',
          color: '#5AD8A6',
        },
      ],
    });
    dualAxes.render();


  // 迷你环形图
  const ringProgress = new RingProgress('container2', {
    height: 100,
    width: 100,
    autoFit: false,
    percent: 0.6,
    color: ['#F4664A', '#E8EDF3'],
    innerRadius: 0.85,
    radius: 0.98,
    statistic: {
      title: {
        style: { color: '#363636', fontSize: '12px', lineHeight: '14px' },
        formatter: () => '进度',
      },
    },
  });

  ringProgress.render();

//柱状图
    const data = [
      { type: '1-3秒', value: 0.16 },
      { type: '4-10秒', value: 0.125 },
      { type: '11-30秒', value: 0.24 },
      { type: '31-60秒', value: 0.19 },
      { type: '1-3分', value: 0.22 },
      { type: '3-10分', value: 0.05 },
      { type: '10-30分', value: 0.01 },
      { type: '30+分', value: 0.015 },
    ];

    const paletteSemanticRed = '#F4664A';
    const brandColor = '#5B8FF9';
    const columnPlot = new Column('container3', {
      data,
      xField: 'type',
      yField: 'value',
      seriesField: '',
      color: ({ type }) => {
        if (type === '10-30分' || type === '30+分') {
          return paletteSemanticRed;
        }
        return brandColor;
      },
      label: {
        content: (originData) => {
          const val = parseFloat(originData.value);
          if (val < 0.05) {
            return (val * 100).toFixed(1) + '%';
          }
        },
        offset: 10,
      },
      legend: false,
      xAxis: {
        label: {
          autoHide: true,
          autoRotate: false,
        },
      },
    });

    columnPlot.render();



  },
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

